package ctn.sdk.youdao.service;

import org.apache.commons.lang.StringUtils;

import ctn.sdk.youdao.config.YouDaoGlobalConfig;

/**
 * Created by Zale on 4/2/14.
 */
public abstract class BaseService {
    private String keyFrom;
    private String key;
    private String baseURL;


    protected BaseService() {
        initDefaults();
    }

    private void initDefaults() {
        if(StringUtils.isEmpty(keyFrom)){
            keyFrom = YouDaoGlobalConfig.KEY_FROM;
        }

        if(StringUtils.isEmpty(key)){
            key=YouDaoGlobalConfig.API_KEY;
        }

        if(StringUtils.isEmpty(baseURL)){
            baseURL=YouDaoGlobalConfig.BASE_URL;
        }
    }

    protected String getKeyFrom(){
        return keyFrom;
    }

    public String getKey() {
        return key;
    }

    public String getBaseURL() {
        return baseURL;
    }
}
